using System;
using System.Threading;
using System.Collections;

namespace WoWAddonRefresh.Entities {
	/// <summary>
	/// Summary description for WorkingThread.
	/// </summary>
	public class WorkingThread {
		public Thread ThreadItem;
		public Guid ID = Guid.NewGuid();
	}

	public class WorkingThreadCollection : CollectionBase {
		public WorkingThreadCollection() {}

		/// <summary>
		/// Adds a WorkingThread to the collection.
		/// </summary>
		/// <param name="newWorkingThread">new WorkingThread</param>
		public int Add(WorkingThread newWorkingThread) {
			return List.Add(newWorkingThread);
		}

		public void Remove(WorkingThread workingThread){
			int index = -1;
			for (int i = 0; i < this.Count; i++) {
				if (this[i].ID == workingThread.ID) index = i;
			}
			if (index >= 0) this.RemoveAt(index);
		}

		/// <summary>
		/// Gets or sets the <see cref="WorkingThread"/> at the specified index.
		/// In C#, this property is the indexer for the IList interface.
		/// </summary>
		public WorkingThread this[int index] {
			get {
				return (WorkingThread)List[index];
			}
			set {
				throw new System.NotSupportedException("Please use the Add() method."); 
			} 
		}	
	}
}
